package com.example.demo.service.invoke;

import com.dingtalk.api.response.OapiRobotSendResponse;
import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.ForestResponse;
import com.example.demo.entity.po.GitHubUserPO;
import org.springframework.stereotype.Component;

/**
 * @author: Bin.L
 * @date: 2021/11/19 0019 15:01
 * @Description: Forest http 调用
 */
@Component
@BaseRequest(
        contentType = "application/json"
)
public interface ForestHttpClient {

    String DING_URL = "https://oapi.dingtalk.com/robot/send?access_token=f15ec95835d8ee60685e12c4423e5aaf4e51c33f6df841feccc54559ad4d09a1";

    /**
     * 给钉钉机器人发送文本消息
     *
     * @param msg
     * @return
     */
    @PostRequest(DING_URL)
    OapiRobotSendResponse sendTextMessage(@JSONBody String msg);

    /**
     * 搜索GitHub 用户信息
     * @param user
     * @return
     */
    @GetRequest("https://api.github.com/search/users?q=${user}")
    ForestResponse<GitHubUserPO> searchGithubUser(@Var("user") String user);
}
